package com.runing.controller;


import com.runing.config.ResponseWrapper;
import com.runing.entity.RClasses;
import com.runing.service.impl.RClassesServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lel
 * @since 2021-03-11
 */
@RestController
@RequestMapping("/rClasses")
@Api(tags = "学院-年级-班级")
public class RClassesController {

    @Autowired
    RClassesServiceImpl rClassesService;

    @ApiOperation("三层树形侧边栏")
    @GetMapping("/HomePage")
    public ResponseWrapper homePage(){
        ResponseWrapper wrapper = rClassesService.homePage();
        return wrapper;
    }

    @ApiOperation("下拉框，返回学期和周数，学院，年级，班级")
    @GetMapping("/getWeek")
    public ResponseWrapper getWeek(){
        ResponseWrapper wrapper = rClassesService.getWeek();
        return wrapper;
    }

    @ApiOperation("删除班级")
    @ApiImplicitParam(name = "clid",value = "班级id")
    @DeleteMapping("/deleteclasses")
    public ResponseWrapper deleteClasses(@RequestParam(name = "clid")Integer clid){
        ResponseWrapper wrapper = rClassesService.deleteClasses(clid);
        return wrapper;
    }

    @ApiOperation("删除某个学院的某个年级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cid",value = "学院id"),
            @ApiImplicitParam(name = "gid",value = "年级id")
    })
    @DeleteMapping("/deletegrade")
    public ResponseWrapper deleteGrade(@RequestParam(name = "cid")Integer cid,
                                       @RequestParam(name = "gid")Integer gid){
        ResponseWrapper wrapper = rClassesService.daleteGrade(cid, gid);
        return wrapper;
    }
}

